<extend name="Public:innerbase"/>
<block name="css">
<style type="text/css">
	td{
		max-width: 700px;
		text-overflow: ellipsis;
		overflow: hidden;
	}
</style>
</block>
<block name="js">
<script type="text/javascript" src="{:STATICS}/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript" src="{:STATICS}/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="{:RES}/js/spark.util.js"></script>
<script type="text/javascript">
$('.btn-edit').click(function(){
	var src = $(this).attr('url');
	var timestamp = (new Date()).getTime();
	if(src.indexOf('?')>0){
		src+='&timestamp='+timestamp;
	}
	else{
		src+='?timestamp='+timestamp;
	}
	$('#modalFrame').attr('src',src);
	$('#menuModal').modal({'backdrop': 'static','keyboard': false});
});

$('#btnSave').on('click', function (e) {
	var ret = $('#modalFrame')[0].contentWindow.submit('callback');
})

/**
 * @method callback 子窗口数据提交成功时调用
 */
function callback(id){
	$('#menuModal').modal('hide');
	location.reload();
}
</script>
</block>  
<block name="content">
<div class="container-fluid">
<if condition="($wx['wxtype'] eq '订阅号') AND ($wx['is_certified'] eq 0)">
<div class="alert alert-info">
	<h3><i class="fa fa-exclamation-triangle fa-lg text-danger"></i>&nbsp;您的公众号不支持生成自定义菜单！</h3>
	请使用服务号，或认证的订阅号！
</div>
<else />
<div class="alert alert-info">
	<i class="fa fa-exclamation-triangle fa-lg"></i>&nbsp;一级菜单最多只能开启3个，二级子菜单最多开启5个!
</div>
<!--<form class="form-inline" role="form" action="" method="post">
	<div class="form-group">
		<label class="control-label" for="appid">AppId:</label>
	</div>
	<div class="form-group">
		<input type="text" class="form-control" value="{$diymen.appid}" id="appid" name="appid" placeholder="APPID" />
	</div>
	<div class="form-group">
		<label class="control-label" for="appsecret">AppSecret:</label>
	</div>
	<div class="form-group">
		<input type="text" class="form-control" value="{$diymen.appsecret}" id="appsecret" name="appsecret" placeholder="AppSecret" />
	</div>
	<div class="form-group">
		<button type="submit" class="btn btn-primary" >保存</button>
	</div>
</form>-->
<div class="page-header">
	<button class="btn btn-success btn-edit" id="iframe1" url="{:U('Diymen/class_edit')}" title="添加主菜单"><span class="glyphicon glyphicon-plus"></span>&nbsp;添加菜单</button>
	<button type="button" onclick="spark.confirm_jump('自定义菜单最多勾选3个，每个菜单的子菜单最多5个，请确认!', '{:U('Diymen/class_send')}');" class="btn btn-primary">生成自定义菜单</button>
	<button type="button" onclick="spark.confirm_jump('是否确定删除微信会话界面的自定义菜单？', '{:U('Diymen/menu_remove')}');" class="btn btn-danger">删除自定义菜单</button>
</div>
<table class="table wm-table-bordered table-striped table-hover"> 
		<thead>
			<tr>
				<th>显示顺序</th>
				<th>主菜单名称</th>
				<th>菜单类型</th>
				<th>关联关键词</th>
				<th>外链URL</th>
				<th>素材ID</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<volist id="class" name="class">
		<tr class="info">
			<td>
				<span>{$class.sort}</span>
			</td>
			<td>
			  <div>
				<span>{$class.title}</span>
			  </div>
			</td>
			<td>
			  <div>
				<span>{$class.type}</span>
			  </div>
			</td>
			<td><span>{$class.keyword}</span></td>
			<td>
			<span>{$class.url}</span>
			<!-- <span><if condition="$class['url'] eq false">无链接地址<else/>{$class.url}</if></span> -->
			</td>

			<td>
			  <div>
				<span>{$class.media_id}</span>
			  </div>
			</td>

			<td>
				<a class="btn btn-default btn-xs btn-edit" url="{:U('Diymen/class_edit',array('id'=>$class['id']))}">修改</a>
				<a class="btn btn-xs btn-danger" href="javascript:spark.confirm_jump('您确定要删除吗?', '{:U('Diymen/class_del',array('id'=>$class['id']))}');">删除</a>
			</td>
		</tr>
		<volist id="class1" name="class['class']">
		<tr>
			<td>
				<span>{$class1.sort}</span>
			</td>
			<td>
				<div class="board">
					<span>┣&nbsp;&nbsp;{$class1.title}</span>
				</div>
			</td>
			<td>
				<span>{$class1.keyword}</span>
			</td>
			<td>
				<span>
					<if condition="$class1['url'] eq false">无链接地址<else/>{$class1.url}</if>
				</span>
			</td>
			<td>
				<a class="btn btn-default btn-xs btn-edit" url="{:U('Diymen/class_edit',array('id'=>$class1['id']))}" title="修改主菜单">修改</a>
				<a class="btn btn-xs btn-danger" href="javascript:spark.confirm_jump('您确定要删除吗?', '{:U('Diymen/class_del',array('id'=>$class1['id']))}');">删除</a>
			</td>
		</tr>
		</volist>
		</volist>
		</tbody>
	</table>
</div>
<!-- Modal -->
<div class="modal fade" id="menuModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">新建菜单项</h4>
			</div>
			<div class="modal-body">
				<iframe id="modalFrame" frameBorder="0" src="{:U('Diymen/class_edit')}" style="width:100%;height:320px;border:0;" ></iframe>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				<button id="btnSave" type="button" class="btn btn-primary">保存</button>
			</div>
		</div>
	</div>
</if>
</div>
</block> 